*Figure 8: Share of "important" Variables by Category

use "Data_ImportantProvisions_240423.dta", clear

foreach question in mean_general mean_func_democ mean_new_democ mean_divided_democ {
	
	
	if "`question'" == "mean_general" local maketitle "General" 
	if "`question'" == "mean_general" local makecolor "maroon"
	
	if "`question'" == "mean_func_democ" local maketitle "Functioning Democracy" 
	if "`question'" == "mean_func_democ" local makecolor "navy"
	
	if "`question'" == "mean_new_democ" local maketitle "New Democracy" 
	if "`question'" == "mean_new_democ" local makecolor "forest_green"
	
	if "`question'" == "mean_divided_democ" local maketitle "Divided Democracy" 
	if "`question'" == "mean_divided_democ" local makecolor "purple"

	gen important_var_`question' = 0
	replace important_var_`question' = 1 if `question' > 3.99
	bysort cat1: egen count_imp_`question' = total(important_var_`question' == 1)
	bysort cat1: gen length_var_`question' = _n
	bysort cat1: egen max_length_`question' = max(length_var_`question')

	bysort cat1: gen share_imp_`question' = count_imp_`question' / max_length_`question'
}

gen order3 = .
replace order3 = 1 if cat1 == "Rights and Duties"
replace order3 = 2 if cat1 == "Judiciary"
replace order3 = 3 if cat1 == "Legislature" 
replace order3 = 4 if cat1 == "Executive"
replace order3 = 5 if cat1 == "Principles and Symbols"
replace order3 = 6 if cat1 == "Elections"
replace order3 = 7 if cat1 == "Culture and Identity"
replace order3 = 8 if cat1 == "Regulation and Oversight"
replace order3 = 9 if cat1 == "International Law"
replace order3 = 10 if cat1 == "Federalism" 
replace order3 = 11 if cat1 == "Special Sections" 
replace order3 = 12 if cat1 == "Amendment"

graph hbar share_imp_mean_general, over(cat1, sort(order3)) ytitle("Share of Important Characteristics", size(small)) bar(1, color(maroon))  blabel(bar, color(black) position(inside) format(%4.2f) size(tiny) gap(-2.5)) 
graph export "Figure_8.pdf", replace

